package cn.shiwei.user.domain;

import cn.shiwei.basic.domain.BaseDomain;
import cn.shiwei.basic.util.MD5Utils;
import cn.shiwei.basic.util.StrUtils;
import lombok.Data;

import java.util.Date;

@Data
public class User extends BaseDomain {

    private String username;
    private String email;
    private String phone;
    private String salt;
    private String password;
    private Integer state;
    private Integer age;
    private Date createtime = new Date();
    private String headImg;
    private Logininfo logininfo;

    public User(String phone, String password, Integer state) {
        // 设置账号启用状态
        this.state = state;
        this.username = phone;
        this.phone = phone;
        this.salt = StrUtils.getComplexRandomString(32);
        // 加盐加密
        this.password = salt + MD5Utils.encrypByMd5(password);
    }

    public User() {
    }
}
